package com.csu.tour.service.impl;

import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import com.csu.tour.entity.Emergency;
import com.csu.tour.mapper.EmergencyMapper;
import com.csu.tour.service.EmergencyService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Component;


import java.util.List;

@Component
public class EmergencyServiceImpl extends ServiceImpl<EmergencyMapper, Emergency> implements EmergencyService {

    @Autowired
    private   EmergencyMapper emergencyMapper;
    private QueryWrapper<Emergency> queryWrapper = new QueryWrapper<>();
    @Override
    public List<Emergency> selectAllEmergency() {
        return emergencyMapper.selectList(null);
    }

    @Override
    public int insertEmergency(Emergency emergency) {
        return emergencyMapper.insert(emergency);
    }

    @Override
    public int deleteEmergency(int id) {
        return emergencyMapper.deleteById(id);
    }

    @Override
    public int updateEmergency(Emergency emergency) {
        return emergencyMapper.updateById(emergency);
    }

    @Override
    public List<Emergency> selectEmergencyByStatus(String status) {
        return emergencyMapper.selectList(queryWrapper.eq("status",status));
    }

    @Override
    public List<Emergency> selectEmergencyByContent(String content) {
        return  emergencyMapper.selectList(queryWrapper.like("content",content));
    }


}
